package thread;

import java.util.concurrent.Semaphore;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2024-09-30
 * Time: 10:26
 */
public class ThreadDemon39 {
    public static void main(String[] args) throws InterruptedException {
        Semaphore semaphore = new Semaphore(1);//资源数限制为1个
        semaphore.acquire();
        System.out.println("p操作");
        semaphore.acquire();//第二次申请
        System.out.println("p操作");
        semaphore.acquire();//第三次申请
        System.out.println("p操作");

    }
}
